<template>
    <view class="adv">
        <view class="flex-column flex-center-center">
            <view class="adv-item" v-for="(item, index) in advImg" :key="item">
                <image mode="widthFix" :src="item" @click="previewImage(item)"></image>
            </view>
        </view>
    </view>
</template>

<script setup>
const advImg = ref([
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-1.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-2.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-3.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-4.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-5.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-6.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-7.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-8.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-9.jpg",
    "http://119.254.154.50:38081/giftApi/mystatic/images/adv/adv-10.jpg",
]);

const previewImage = (url) => {
    // 预览图片
    uni.previewImage({
        urls: [url],
        longPressActions: {
            itemList: ["发送给朋友", "保存图片", "收藏"],
            success: function (data) {
                console.log("选中了第" + (data.tapIndex + 1) + "个按钮,第" + (data.index + 1) + "张图片");
            },
            fail: function (err) {
                console.log(err.errMsg);
            },
        },
    });
};
</script>

<style lang="scss" scoped>
.adv {
    background: #f6f6f6;
    padding-bottom: 60rpx;

    .adv-item {
        margin-top: 30rpx;

        image {
            width: 690rpx;
            border-radius: 10px;
        }
    }
}
</style>
